document.addEventListener('UniAppJSBridgeReady', function() {
  console.log("UniAppJSBridgeReady");
  const urlSearchParams = new URLSearchParams(window.location.search);
  const params = Object.fromEntries(urlSearchParams.entries());
  const code = params.code;
  if(code){
    uni.postMessage({
      data: {
        code: code
      }
    });
  }else{
    console.log("缺少code参数");
    uni.postMessage({
      data: {
        code: null,
        msg: "缺少code参数"
      }
    });
  }
  setTimeout(() => {
    wx.miniProgram.navigateBack();
  }, 1000);
});